<?php

class q_request {

    public static function get($what, $type = 'str', $default = null){
        return self::_req($_GET, $what, $type, $default);
    }

    public static function post($what, $type = 'str', $default = null){
        return self::_req($_POST, $what, $type, $default);
    }

    public static function cookie($what, $type = 'str', $default = null){
        return self::_req($_COOKIE, $what, $type, $default);
    }

    public static function _req($arr, $what, $type = 'str', $default = null){
        if(isset($arr[$what])){
            if($type == 'int'){
                return intval($arr[$what]);
            } else if($type == 'number'){
                $var = intval($arr[$what]);
                if($var < 1){
                    return $default;
                } else {
                    return $var;
                }
            } else {
                return $arr[$what];
            }
        } else {
            return $default;
        }
    }
}
